//
//  FKMineCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/21.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKMineCell.h"

@interface FKMineCell ()

@property (nonatomic, weak) UIImageView *container;
@property (nonatomic, weak) UIImageView *iconView;
@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UIView *separator;

@end

@implementation FKMineCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.backgroundColor = [UIColor clearColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIImageView *container = [[UIImageView alloc] init];
    [self.contentView addSubview:container];
    self.container = container;
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [container addSubview:iconView];
    self.iconView = iconView;
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(15) textColor:fkColor333333];
    [container addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UIImageView *arrowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rightarrow"]];
    [container addSubview:arrowView];
    
    UIView *separator = [[UIView alloc] init];
    [self.contentView addSubview:separator];
    self.separator = separator;
    separator.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.right.offset(-12);
        make.top.bottom.offset(0);
    }];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.centerY.offset(0);
        make.width.height.offset(fk_adjustW(20));
    }];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(8);
        make.centerY.offset(0);
    }];
    [arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(fk_adjustW(-16));
        make.centerY.offset(0);
    }];
    [separator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(container);
        make.height.offset(0.8);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    self.container.image = [UIImage imageNamed:data[@"bgImg"]];
    self.iconView.image = [UIImage imageNamed:data[@"icon"]];
    self.titleLabel.text = data[@"title"];
    self.separator.hidden = [data[@"hideSeparator"] boolValue];
}

@end
